home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / os2 / remin301.zip / REMIN300.ZIP / REMIND-A.SH < prev    next >
Text File  |  1992-11-10  |  2KB  |  47 lines

  1. # Shell script to mail all users reminders.
  2.  
  3. # Thanks to Bill Aten for this script.
  4.  
  5. # Run it AFTER MIDNIGHT so that date is correct!
  6. # On our system, we have the following in our crontab:
  7. # 02 00 * * * /usr/local/adm/remind-all >/dev/null 2>&1
  8.  
  9. # Also, you MUST use the -r and -q options on REMIND, otherwise a SEVERE
  10. # security hole could develop.  I recommend making this script
  11. # readable and executable only by root to minimize security problems.
  12. # DO NOT make the script setuid!
  13.  
  14. # The following line gets a list of users for systems using SUN's
  15. # NIS service:
  16. # USERS=`ypcat passwd | awk -F: '{print $1}'`
  17.  
  18. # The following line gets a list of users by examining /etc/passwd:
  19. USERS=`awk -F: '{print $1}' /etc/passwd`
  20.  
  21. # If neither of the above methods works, you must come up with some
  22. # way of getting a list of users on the system
  23.  
  24. # Set the following variables as appropriate for your system
  25. REMIND=/usr/local/bin/remind
  26. MAIL=/usr/bin/mail
  27. RM="/bin/rm -f"
  28.  
  29. REMFILE=/tmp/RemFile.$$
  30.  
  31. # Scan each user's directory for a .reminders file
  32. for i in $USERS
  33. do
  34. HOME=`grep \^$i: /etc/passwd | awk -F: '{print $6}'`
  35.    if [ -r $HOME/.reminders ]; then
  36.  
  37. #     echo "$i has a .reminders file."     DEBUGGING PURPOSES ONLY
  38.  
  39.       su - $i -c "$REMIND -rqh $HOME/.reminders" < /dev/null > $REMFILE
  40.       if [ -s $REMFILE ]; then
  41. #        echo "Sending mail to $i"         DEBUGGING PURPOSES ONLY
  42.          $MAIL -s "Reminders" $i < $REMFILE
  43.       fi
  44.       $RM $REMFILE
  45.    fi
  46. done
  47.